<template>
  <view class="content">
    <view class="box">
      <view>
        <!-- <AtInput
          name='name1'
          type='number'
          :border="false"
          placeholder='请输入用户手机号'
          :value="mobile"
          @change="changeMobile"
        >
        </AtInput> -->
        <input class="inp" type="text" v-model="mobile" placeholder='请输入用户手机号'/>
      </view>
       <AtButton type='primary' class="button" @tap="getUserInfo">查询用户</AtButton>
    </view>
    
    <AtToast :isOpened="market.isShow" :text="market.text" icon="close"></AtToast>
  </view>
</template>

<script>
import './search.scss';
import Taro from '@tarojs/taro';
import UserAPI from "../../api/user.js"
import { getUrlArgObject } from '../../utils/spliturl'
export default {
  data(){
    return{
      mobile: "",
      market: {
        isShow: false,
        text: "",
      }
    }
  },
  methods: {
    changeMobile(val){
      this.mobile = val;
    },
    // 获取用户数据
    getUserInfo() {
      // 手机号
      if (this.mobile.length == 11 ) {
        var data = {
          token: Taro.getStorageSync('token'),
          app_id: Taro.getStorageSync('app_id'),
          page: 1,
          point_order: 0,
          mobile: this.mobile
        };
        UserAPI.getUserList(data).then(res => {
          if (res.code == 200) {
            this.show_user_infor = true;
            if (res.data.result.length > 0) {
              this.user_infor = res.data.result[0];
              Taro.setStorageSync('userInfor', this.user_infor);
              // 获取详细用户信息
              Taro.navigateTo({
                url: "/pages/userMenu/menuIndexH5"
              })
            } else{
              this.market.isShow = true;
              this.market.text = "该用户没有用户信息！！！";
              console.log("该用户没有用户信息！！！");
            }
          }else{
            this.market.isShow = true;
            this.market.text = res.msg;
          }
        });
      } else{
        // 
        this.market.isShow = true;
        this.market.text = "请输入正确的手机号！！";
      }
    },
  }
}

</script>
